package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * 将”./src/main/java/io“目录下的所有.java文件内容都输出到控制台上
 * 思路：
 *
 */
public class Test3 {
    public static void main(String[] args) throws IOException {
        File dir = new File("./src/main/java/io");
        FileFilter filter = new FileFilter() {
            public boolean accept(File file) {
                String name = file.getName();
                System.out.println(name);
                return name.endsWith(".java");
            }
        };
        File[] subs = dir.listFiles(filter);
        for(int i=0;i<subs.length;i++){
            FileInputStream fis =  new FileInputStream(subs[i]);
            long len = subs[i].length();
            byte[] data = new byte[(int)len];
            fis.read(data);
            String line = new String(data, StandardCharsets.UTF_8);
            System.out.println(line);
        }
    }
}
